# -!- coding: utf-8 -!-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#文件：postMsreport.py
触发报送信息的接口
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


import requests

yhqb_url = 'http://10.16.20.202:8234/'
qdzj_url = 'https://test.coo.msxiaodai.com/'
report_url = 'http://10.16.20.202:8200/'             # web服务
msydloan_url = 'https://test.zyjk.msxiaodai.com/'


headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36'
        }


def pushQdzjmsloan():
    fu_url = qdzj_url + 'qdzj/baihang/pushHst'
    print(fu_url)
    req1 = requests.post(fu_url,headers=headers)
    data = req1.text
    print(data)


def pushQbmsloan():
    fu_url = yhqb_url + 'yhqb/baihang/pushHst'
    print(fu_url)
    req1 = requests.post(fu_url,headers=headers)
    data = req1.text
    print(data)


# data_type IN('LoanContract', 'LoanInfo', 'Repay', 'ContractLoss') and result IN('F', 'N')
def exec_JRJ_push():
    fu_url = msydloan_url + 'supervise/pushNoSuccess'
    print(fu_url)
    req1 = requests.post(fu_url, headers=headers)
    print("中移动系统对金融局报送的推送状态N+F记录重新推送自动任务完成！", req1, req1.text)

# 报送平台日结触发
def JRJ_day_report():
    fu_url = report_url + 'test/dayReport'
    print(fu_url)
    req1 = requests.get(fu_url, headers=headers)
    print("报送平台系统日结统计自动任务完成！", req1, req1.text)

# data_type IN('LoanApply', 'SingleLoanAccount', 'SingleLoanRepay') and result IN('F', 'N')
def exec_baihang_push():
    fu_url = msydloan_url + 'baihang/pushNoSuccess'
    print(fu_url)
    req1 = requests.post(fu_url, headers=headers)
    print("中移动系统对百行报送的推送状态N+F记录重新推送自动任务完成！", req1, req1.text)


# 金融局放款、合同存量报送(从ms_loan表拿4、6、7状态的数据)
def push_stock_loan():
    fu_url = msydloan_url + 'test/pushLoan'
    print(fu_url)
    req1 = requests.post(fu_url, headers=headers)
    print("中移动金融局放款、合同存量报送任务完成：", req1, req1.text)


# 金融局存量还款数据报送(从ms_repay_order表拿S状态的数据)
def push_stock_repay():
    fu_url = msydloan_url + 'test/pushRepay'
    print(fu_url)
    req1 = requests.get(fu_url, headers=headers)
    print("中移动金融局存量还款数据报送任务完成：", req1, req1.text)


# 百行数据推送
def exec_reportBatch():
    fu_url = report_url + 'baiHang/hstPush'
    print(fu_url)
    req1 = requests.post(fu_url, headers=headers)
    print("执行报送批量自动任务完成：", req1, req1.text)

# 所有百行申请信息文件报送(报送平台拿数据)
def hbBaiHangPushByDay():
    fu_url = report_url + 'report/hbBaiHangPushByDay'
    print(fu_url)
    req1 = requests.post(fu_url,headers=headers)
    data = req1.text
    print(data)

# 昨天百行申请信息文件报送(报送平台拿数据)
def hbBaiHangPush():
    fu_url = report_url + 'report/hbBaiHangPush'
    print(fu_url)
    req1 = requests.post(fu_url,headers=headers)
    data = req1.text
    print(data)


if __name__ == '__main__':
    i = 7
    if i ==0:
        exec_JRJ_push()              # N+F状态记录重新推送
    if i == 8:
        exec_baihang_push()
    elif i == 1:
        push_stock_loan()            # 金融局存量-放款、合同报送
    elif i == 2:
        push_stock_repay()           # 金融局存量-还款数据报送
    elif i == 3:
        exec_reportBatch()           # 报送平台
    elif i == 4:
        hbBaiHangPushByDay()         # 所有百行申请信息文件报送
    elif i == 5:
        hbBaiHangPush()              # 昨天百行申请信息文件报送
    elif i == 6:
        pushQdzjmsloan()
    elif i == 7:
        JRJ_day_report()